﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HFK.DxFluentUI.HorizontalGrid;
using HFK.DxFluentUITest.Dummy.DataObjects;

namespace HFK.DxFluentUITest.Dummy
{
  public class HorizontalGridWithColumns : HorizontalGridControlBase
  {
    public HorizontalGridWithColumns()
    {
      View<SimpleClass>("View1",
        v1 =>
        {
          v1.AddColumn("Column1");
          v1.AddColumn("Column2", d => d.IntValue);
          v1.AddColumn("Column3").BindToProperty(d => d.StringValue);
          v1.AddColumn("Column4").BindToProperty(d => d.ShcData.DhcProperty.ThcProperty.StringProperty);
        });
    }
  }

  //public class HorizontalGridWithColumnsBanding : HorizontalGridControlBase
  //{
  //  public HorizontalGridWithColumnsBanding()
  //  {
  //    View<SimpleClass>("View1",
  //      v1 =>
  //      {
  //        v1.AddCategory("Category1", 
  //          c1 =>
  //          {
  //            c1.AddColumn("Column1");
  //            c1.AddColumn("Column2", d => d.IntValue);
  //            c1.AddColumn("Column3").Bind(d => d.StringValue);
  //            c1.AddColumn("Column4").Bind(d => d.ShcData.DhcProperty.ThcProperty.StringProperty);
  //          });
  //      });
  //  }
  //}

  //public class HorizontalGridWithColumnsNestedBanding : HorizontalGridControlBase
  //{
  //  public HorizontalGridWithColumnsNestedBanding()
  //  {
  //    View<SimpleClass>("View1",
  //      v1 =>
  //      {
  //        v1.AddCategory("Category1", 
  //          c1 =>
  //          {
  //            c1.AddCategory("Category11",
  //              c11 =>
  //              {
  //                c1.AddColumn("Column1");
  //                c1.AddColumn("Column2", d => d.IntValue);
  //              });
  //            c1.AddCategory("Category12",
  //              c12 =>
  //              {
  //                c12.AddColumn("Column3").Bind(d => d.StringValue);
  //              });
  //            c1.AddCategory("Category13",
  //              c13 =>
  //              {
  //                c13.AddColumn("Column4").Bind(d => d.ShcData.DhcProperty.ThcProperty.StringProperty);
  //              });
  //          });
  //      });
  //  }
  //}

  public class HorizontalGridIsReadOnly : HorizontalGridControlBase
  {
    public HorizontalGridIsReadOnly()
    {
      View<SimpleClass>("View1",
        v1 =>
        {
          v1.WithEditing().Allowed();
          v1.AddColumn("Column1");
          v1.AddColumn("Column2", d => d.IntValue);
          v1.AddColumn("Column3").BindToProperty(d => d.StringValue);
          v1.AddColumn("Column4").BindToProperty(d => d.ShcData.DhcProperty.ThcProperty.StringProperty);
        });
    }
  }

  public class HorizontalGridIsEditable : HorizontalGridControlBase
  {
    public HorizontalGridIsEditable()
    {
      View<SimpleClass>("View1",
        v1 =>
        {
          v1.WithEditing().Allowed();
          v1.AddColumn("Column1");
          v1.AddColumn("Column2", d => d.IntValue);
          v1.AddColumn("Column3").BindToProperty(d => d.StringValue);
          v1.AddColumn("Column4").BindToProperty(d => d.ShcData.DhcProperty.ThcProperty.StringProperty);
        });
    }
  }

  public class HorizontalGridColumnsEditable : HorizontalGridControlBase
  {
    public HorizontalGridColumnsEditable()
    {
      View<SimpleClass>("View1",
        v1 =>
        {
          v1.AddColumn("Column1").BindToProperty(d => d.DateValue).And().WithEditing().Allowed();
          v1.AddColumn("Column2").BindToProperty(d => d.IntValue).And().WithEditing().NotAllowed(); 
        });
    }
  }

  public class HorizontalGridColumnsEditableFromDomain : HorizontalGridControlBase
  {
    public HorizontalGridColumnsEditableFromDomain()
    {
      View<SimpleClass>("View1",
        v1 =>
        {
          v1.AddColumn("Column1").BindToProperty(d => d.IntValue).And().WithEditing().AllowedUsing().Values(new int[] { 1, 1, 2, 3, 5, 8 });
          v1.AddColumn("Column2").BindToProperty(d => d.StringValue).And().WithEditing().AllowedUsing().Objects<SingleHopClass>(null).InDropdownBoxEditor(
            de =>
            {
              de.DisplayProperty(d => d.TextValue);
              de.AssignValue().FromProperty(d => d.StringValue);
            });
          v1.AddColumn("Column3").BindToProperty(d => d.StringValue).And().WithEditing().AllowedUsing().Objects<SingleHopClass>(null).InDropdownGridEditor(
            de =>
            {
              de.DisplayProperty(d => d.TextValue);
              de.AssignValue().FromObject();
              de.AddColumn("DomEditColumn2", d => d.StringValue);
            });
        });
    }
  }

  public class HorizontalGridOptimizeColumnWidthForView : HorizontalGridControlBase
  {
    public HorizontalGridOptimizeColumnWidthForView()
    {
      View<SimpleClass>("View1",
        v1 =>
        {
          v1.OptimizeColumnWidthForView();
          v1.AddColumn("Column1");
          v1.AddColumn("Column2", d => d.IntValue);
          v1.AddColumn("Column3").BindToProperty(d => d.StringValue);
          v1.AddColumn("Column4").BindToProperty(d => d.ShcData.DhcProperty.ThcProperty.StringProperty);
        });
    }
  }

  public class HorizontalGridOptimizeColumnWidthForText : HorizontalGridControlBase
  {
    public HorizontalGridOptimizeColumnWidthForText()
    {
      View<SimpleClass>("View1",
        v1 =>
        {
          v1.OptimizeColumnWidthForText();
          v1.AddColumn("Column1");
          v1.AddColumn("Column2", d => d.IntValue);
          v1.AddColumn("Column3").BindToProperty(d => d.StringValue);
          v1.AddColumn("Column4").BindToProperty(d => d.ShcData.DhcProperty.ThcProperty.StringProperty);
        });
    }
  }

  public class HorizontalGridAllowGrouping : HorizontalGridControlBase
  {
    public HorizontalGridAllowGrouping()
    {
      View<SimpleClass>("View1",
        v1 =>
        {
          v1.WithGrouping().Allowed();
          v1.AddColumn("Column1");
          v1.AddColumn("Column2", d => d.IntValue);
          v1.AddColumn("Column3").BindToProperty(d => d.StringValue);
          v1.AddColumn("Column4").BindToProperty(d => d.ShcData.DhcProperty.ThcProperty.StringProperty);
        });
    }
  }

  public class HorizontalGridDisallowGrouping : HorizontalGridControlBase
  {
    public HorizontalGridDisallowGrouping()
    {
      View<SimpleClass>("View1",
        v1 =>
        {
          v1.WithGrouping().NotAllowed();
          v1.AddColumn("Column1");
          v1.AddColumn("Column2", d => d.IntValue);
          v1.AddColumn("Column3").BindToProperty(d => d.StringValue);
          v1.AddColumn("Column4").BindToProperty(d => d.ShcData.DhcProperty.ThcProperty.StringProperty);
        });
    }
  }

  public class HorizontalGridWithColumnsSorting : HorizontalGridControlBase
  {
    public HorizontalGridWithColumnsSorting()
    {
      View<SimpleClass>("View1",
        v1 =>
        {
          v1.AddColumn("Column1");
          v1.AddColumn("Column2", d => d.IntValue).WithSorting().Allowed();
          v1.AddColumn("Column3").BindToProperty(d => d.StringValue).And().WithSorting().NotAllowed();
          v1.AddColumn("Column4").BindToProperty(d => d.ShcData.DhcProperty.ThcProperty.StringProperty);
        });
    }
  }

  public class HorizontalGridWithColumnsFiltering : HorizontalGridControlBase
  {
    public HorizontalGridWithColumnsFiltering()
    {
      View<SimpleClass>("View1",
        v1 =>
        {
          v1.AddColumn("Column1");
          v1.AddColumn("Column2", d => d.IntValue).WithFiltering().Allowed();
          v1.AddColumn("Column3").BindToProperty(d => d.StringValue).And().WithFiltering().NotAllowed();
          v1.AddColumn("Column4").BindToProperty(d => d.ShcData.DhcProperty.ThcProperty.StringProperty);
        });
    }
  }

  //public class HorizontalGridWithColumnsCustomFiltering : HorizontalGridControlBase
  //{
  //  public HorizontalGridWithColumnsCustomFiltering()
  //  {
  //    View<SimpleClass>("View1",
  //      v1 =>
  //      {
  //        v1.AddColumn("Column1");
  //        v1.AddColumn("Column2", d => d.IntValue).AllowFiltering().AllStandardFilters();
  //        v1.AddColumn("Column3", d => d.DateValue).AllowFiltering().AddCustomFilters(
  //          f1 =>
  //          {
  //            f1.AddStandardFilter(StandardDateFilter.ToDay);
  //            f1.AddStandardFilter(StandardDateFilter.ThisWeek);
  //            f1.AddStandardFilter(StandardDateFilter.ThisMonth);
  //            f1.AddStandardFilter(StandardDateFilter.ThisYear);
  //          }
  //          );
  //        v1.AddColumn("Column4").BindToProperty(d => d.StringValue).AllowFiltering().AddCustomFilters(
  //          f1 =>
  //          {
  //            f1.AddFilter().WithCaption("EqualTo<Test>").AndFilterExpression(v => v == "Test");
  //            f1.AddFilter().WithCaption("EqualTo<AnotherTest>").AndFilterExpression(v => v == "AnotherTest");
  //          }
  //          );
  //        v1.AddColumn("Column5").BindToProperty(d => d.ShcData.DhcProperty.ThcProperty.StringProperty);
  //      });
  //  }
  //}
}
